﻿using DeepEarth.Map.Core;
using System;
using DeepEarth.Map.Core.Utilities;
using DeepEarth.Map.Core.Tiling;
namespace DeepEarth.Map.TileSources
{
    public class XYZTileSource : BaseTileSource
    {
        private const int DefaultMaxZoomLevel = 18;
        private const int DefaultTileSize = 256;

        public XYZTilePath PathFormatter { get; set; }

        public XYZTileSource()
            : base(XYZTileSourceFactory.XYZ, (int)Math.Pow(2, DefaultMaxZoomLevel) * DefaultTileSize,
                   (int)Math.Pow(2, DefaultMaxZoomLevel) * DefaultTileSize,
                   DefaultTileSize,
                   DefaultTileSize,
                    0)
        {
            PathFormatter = new XYZTilePath();
        }

        protected override void GetTileLayers(int tileLevel, int tilePositionX, int tilePositionY, System.Collections.Generic.IList<object> tileImageLayerSources)
        {
            string path = PathFormatter.GetUri(tileLevel, tilePositionX, tilePositionY);
            tileImageLayerSources.Add(new Uri(path));
        }

	}
}
